package com.wondersgroup.fjzlpt.org.dao.impl.tdgl;

import java.util.Map;

import com.wondersgroup.fjzlpt.org.util.ControllerCommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.page.PageQuerySQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.quick.framework.boot.repository.sql.jdbcTemplate.rs.ResultHandlerConstant;
import com.wondersgroup.fjzlpt.org.dao.inter.tdgl.TdrjDao;

@Repository
public class TdrjDaoImpl extends BaseJTDAOImpl implements TdrjDao {
	
	@Override
	@Autowired
	@Qualifier("TB_TDGL_TDRJ")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}
	
	@Override
	public JSONObject queryLogsByPage(Map<String, String> map) {
		ControllerCommonUtil.pageFormat(map);
		StringBuffer sqlBuf = new StringBuffer("select a.*,")
				.append("(select XM from TB_ZD_YLJGRYXX where USERID=a.CZRID) CZR,")
				.append("(select XM from TB_ZD_YLJGRYXX where USERID=a.YSID) CZDX from ")
				.append(this.tb.getTableName())
				.append(" a where a.TDID = ? ");

		PageQuerySQLBean pageBean = super.checkAndCreatePageQuerySQLBean(map, sqlBuf.toString(),"order by a.JLSJ desc",map.get("TDID"));
		return super.queryPage(pageBean, ResultHandlerConstant.JSONARRAY);
	}

}
